package com.googlecode.hmvc4gwt.example.hmvcblog.service.gwtrpc.server.blog.entry.comment;

import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.BlogEntryIdDTO;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.comment.BlogEntryCommentDTO;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.comment.BlogEntryCommentEditDTO;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.comment.BlogEntryCommentNewDTO;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.comment.BlogEntryCommentRemoveDTO;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.comment.exceptions.BlogEntryCommentAuthorNameEmptyException;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.comment.exceptions.BlogEntryCommentNotFoundException;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.comment.exceptions.BlogEntryCommentTextEmptyException;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.entry.exceptions.BlogEntryNotFoundException;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.blog.exceptions.NotBlogOwnerException;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.dto.user.exception.NotLoggedInException;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.gwtrpc.client.blog.entry.comment.IBlogEntryCommentRemoteService;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.gwtrpc.server.ApplicationContext;
import com.googlecode.hmvc4gwt.example.hmvcblog.service.services.blog.entry.comment.IBlogEntryCommentService;

public class BlogEntryCommentRemoteServiceImpl extends RemoteServiceServlet implements IBlogEntryCommentRemoteService {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
	
	private IBlogEntryCommentService blogEntryCommentService;

	public BlogEntryCommentRemoteServiceImpl() {
		setBlogEntryCommentService((IBlogEntryCommentService) ApplicationContext.getBean("blogEntryCommentService"));
	}

	public void addBlogEntryComment(BlogEntryCommentNewDTO commentNewDTO) throws BlogEntryCommentTextEmptyException, BlogEntryCommentAuthorNameEmptyException, BlogEntryNotFoundException {
		getBlogEntryCommentService().addBlogEntryComment(commentNewDTO);
	}

	public void editBlogEntryComment(BlogEntryCommentEditDTO commentEditDTO) throws BlogEntryCommentTextEmptyException, BlogEntryCommentAuthorNameEmptyException, BlogEntryNotFoundException, BlogEntryCommentNotFoundException, NotLoggedInException, NotBlogOwnerException {
		getBlogEntryCommentService().editBlogEntryComment(commentEditDTO);
	}

	public IBlogEntryCommentService getBlogEntryCommentService() {
		return blogEntryCommentService;
	}

	public List<BlogEntryCommentDTO> getListBlogEntryCommentDTO(
			BlogEntryIdDTO blogEntryIdDTO) throws BlogEntryNotFoundException {
		return getBlogEntryCommentService().getListBlogEntryCommentDTO(blogEntryIdDTO);
	}

	public void removeBlogEntryComment(
			BlogEntryCommentRemoveDTO commentRemoveDTO) throws NotLoggedInException, NotBlogOwnerException, BlogEntryCommentNotFoundException {
		getBlogEntryCommentService().removeBlogEntryComment(commentRemoveDTO);
	}

	public void setBlogEntryCommentService(IBlogEntryCommentService blogEntryCommentService) {
		this.blogEntryCommentService = blogEntryCommentService;
	}
}
